<cfcomponent extends="Controller">
	<cffunction name="evaluation">
		<cfscript>
			var documentID = 10;	
			document = {
					"main" = getDoctorsDocument(documentID),
					"medication" = model("doctors_currentMedications").findAll(where="consumerID = #PARAMS.key#"),
					"allergies" = model("allergies").findAll(where="consumerID = #PARAMS.key#"),
					"medicalHistory" = model("doctors_medicalHistory").findAll(where="consumerID = #PARAMS.key#"),
					"outpatient" = model("doctors_outpatientTreatments").findAll(where="consumerID = #PARAMS.key#"),
					"substanceAbuse" = model("doctors_substanceAbuse").findAll(where="consumerID = #PARAMS.key#")
			};
		</cfscript>
	</cffunction>
	
	<cffunction name="getDoctorsDocument">
		<cfargument name="documentID" default="0">
		<cfscript>
			consumer = Model("consumer").findByKey(key=PARAMS.key, returnAs="query");
			insuranceDocuments = Model("document").findAll(include="doctor", where="id=#ARGUMENTS.documentID# AND consumerID=#PARAMS.key#");
		</cfscript>
		<cfquery name="document" dbtype="query">
			SELECT 	*, (consumer.firstName + ' ' + consumer.lastName) [consumerName]
			FROM 	insuranceDocuments, consumer 
			WHERE 	insuranceDocuments.consumerID = consumer.id
		</cfquery>
		<cfreturn document>
	</cffunction>
</cfcomponent>